package com.euond.accv.mdm.service;

import com.euond.accv.mdm.client.dto.MdmCustomerDTO;
import com.euond.accv.mdm.dao.MdmCustomerDao;
import com.euond.accv.mdm.domain.MdmCustomer;
import com.euond.common.dao.BaseDao;
import com.euond.common.service.BaseSimplePageService;
import com.euond.common.util.BeanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("mdmCustomerService")
public class MdmCustomerService extends BaseSimplePageService<MdmCustomer, String>{
	@Autowired
	public MdmCustomerDao dao;
	
	@Override
	protected BaseDao<MdmCustomer, String> init() {
		return dao;
	}

	public List<MdmCustomerDTO> findCustomerByNo(String customerNo){
		List<MdmCustomer> dtoList = dao.findByCustomerNo(customerNo);

		List<MdmCustomerDTO> list = new ArrayList<MdmCustomerDTO>();
		if(dtoList!=null && dtoList.size()>0){
			list = BeanMapper.mapList(dtoList, MdmCustomerDTO.class);
		}
		return list;
	}
}
